package com.panghu.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panghu.entity.Message;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 留言表 Mapper 接口
 * </p>
 *
 * @author huahua
 * @since 2022-03-19
 */
public interface MessageMapper extends BaseMapper<Message> {

    //查询所有评论和附加评论
    @Select("select * from message")
    @Results({
            @Result(property = "replays", column = "id",many = @Many(select = "com.panghu.mapper.ReplayMapper.selectById"))
    })
    public IPage<Message> findAll(Page page);

    //根据用户id进行评论查询
    @Select("select * from message where id = #{id}")
    @Results({
            @Result(property = "replays", column = "id",many = @Many(select = "com.panghu.mapper.ReplayMapper.selectById"))
    })
    public Message findById(Integer id);


}
